﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Eieboom
{
    public class ZhTWRegistration : AreaRegistration
    {
        public override string AreaName
        {
            get
            {
                return "LangZhTW";
            }
        }

        public override void RegisterArea(AreaRegistrationContext context)
        {
            //首页
            context.MapRoute(
                "zh-tw_Index",
                "zh-tw/{pageNo}",
                new { controller = "Home", action = "Index", pageNo = UrlParameter.Optional },
                new { pageNo = "[0-9]*" }
            );

            //Rss
            context.MapRoute(
                "zh-tw_Rss",
                "zh-tw/rss/",
                new { controller = "Home", action = "Rss" }
            );

            //Comment Rss
            context.MapRoute(
                "zh-tw_CommentRss",
                "zh-tw/commentrss/",
                new { controller = "Home", action = "CommentRss" }
            );

            //分类,id号查看
            context.MapRoute(
                "zh-tw_Category",
                "zh-tw/cate/{id}/{pageNo}",
                new { controller = "Home", action = "Category", pageNo = UrlParameter.Optional },
                new { id = "[0-9]+", pageNo = "[0-9]*" }
            );

            //文章,id查看
            context.MapRoute(
                "zh-tw_Article",
                "zh-tw/archive/{id}",
                new { controller = "Home", action = "Article" },
                new { id = "[0-9]+" }
            );

            //文章查看,别名查看
            context.MapRoute(
                "zh-tw_ArticleByKey",
                "zh-tw/article/{key}",
                new { controller = "Home", action = "ArticleByKey" },
                new { key = @"^[a-zA-Z0-9\-]+$" }

            );

            //相册查看,id查看
            context.MapRoute(
                "zh-tw_Album",
                "zh-tw/album/{id}",
                new { controller = "Home", action = "Album" },
                new { id = "[0-9]+" }
            );

            //标签查看
            context.MapRoute(
                "zh-tw_Tag",
                "zh-tw/tag/{key}/{pageNo}",
                new { controller = "Home", action = "Tag", pageNo = UrlParameter.Optional },
                new { pageNo = "[0-9]*" }
            );

            //搜索
            context.MapRoute(
                "zh-tw_Search",
                "zh-tw/search/{key}/{pageNo}",
                new { controller = "Home", action = "Search", pageNo = UrlParameter.Optional },
                new { pageNo = "[0-9]*" }
            );

            //文章归档
            context.MapRoute(
                "zh-tw_Archives",
                "zh-tw/Archives/{year}/{month}/{pageNo}",
                new { controller = "Home", action = "Archives", pageNo = UrlParameter.Optional },
                new { year = "[0-9]+", month = "[0-9]+", pageNo = "[0-9]*" }
            );

            //文章按天归档
            context.MapRoute(
                "zh-tw_ArchivesDate",
                "zh-tw/Archives/{year}-{month}-{day}/{pageNo}",
                new { controller = "Home", action = "ArchivesDate", pageNo = UrlParameter.Optional },
                new { year = "[0-9]+", month = "[0-9]+", day = "[0-9]+", pageNo = "[0-9]*" }
            );

            //留言查看
            context.MapRoute(
                "zh-tw_NoteBook",
                "zh-tw/NoteBook/{pageNo}",
                new { controller = "Home", action = "NoteBook", pageNo = UrlParameter.Optional },
                new { pageNo = "[0-9]*" }
            );

            //分类,别名查看
            context.MapRoute(
                "zh-tw_CategoryByKey",
                "zh-tw/{key}/{pageNo}",
                new { controller = "Home", action = "CategoryByKey", pageNo = UrlParameter.Optional },
                new { key = @"^[a-zA-Z0-9\-]+$", pageNo = "[0-9]*" }
            );

            //默认路由
            context.MapRoute(
                "zh-tw_Default", // 路由名称
                "zh-tw/{controller}/{action}/{id}", // 带有参数的 URL
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // 参数默认值
            );
        }
    }

}